﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Net.Mail;

namespace mBlog.Core.Filters
{
    public class CommentNotificationAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!filterContext.Canceled)
            {
                MailMessage message = new MailMessage();
                message.To.Add(new MailAddress("jun1st.feng@gmail.com"));
                message.Subject = "New Comment";
                message.Body = "New Comment Added";

                SmtpClient client = new SmtpClient();

                client.SendAsync(message, null);
                
            }
            base.OnActionExecuted(filterContext);
        }
    }
}
